
try:
	while True:
		dc = {}
		n = input()
		for x in range(n):
			f,b = map(int, raw_input().split())
			if f not in dc: dc[f] = [0, 0]
			if b not in dc: dc[b] = [0, 0]
			if f==b:
				dc[f][0] += 1
			else:
				dc[f][0] += 1
				dc[b][0] += 1
				dc[b][1] += 1
		ans = 1<<29;
		tar = (n+1)/2
		for v in dc.itervalues():
			if v[0]<tar: continue
			t = tar - (v[0] - v[1])
			if t < 0: t = 0
			ans = min(ans, t)

		print ans if ans!= (1<<29) else -1



except Exception,e:
	pass
